package research.reflection;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.MethodUtils;

import junit.framework.TestCase;

public class Test1 extends TestCase {
	
	@SuppressWarnings("unchecked")
	public void test1() {
		Hello h1 = new Hello();
		assertEquals("hello", h1.hi());
		try {
			assertEquals("hello", MethodUtils.invokeMethod(h1, "hi", null));
		} catch (NoSuchMethodException e) {
			fail(e.getMessage());
		} catch (IllegalAccessException e) {
			fail(e.getMessage());
		} catch (InvocationTargetException e) {
			fail(e.getMessage());
		}
	}
}

class Hello {
	
	public String hi() {
		return "hello";
	}
}
